package com.example.myspringpro.config;

import org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator;
import org.hibernate.validator.resourceloading.PlatformResourceBundleLocator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;


/**
 * @Description
 * @Author allenhu <huxiangneng@163.com>
 * @Date 2019/05/08
 * @Version V1.0.0
 **/
//@Configuration
public class ValidatorConfiguration {
//    @Bean
    public Validator validator(){
        Validator validator = Validation.byDefaultProvider().
                configure().
                messageInterpolator(new ResourceBundleMessageInterpolator(new PlatformResourceBundleLocator("i18n/validation/message"))).
                buildValidatorFactory().getValidator();

        return validator;
    }
}
